import { UserProfilesApi } from "@/request/api"
export default {
    namespaced: true,
    state: {
        userInfo: {
            nickName: "zhangsan",
            coin: 9999,
            headImg: require("../../assets/img/service.848ec511.png")
        },
        cartTotal: 8
    },
    mutations: {
        changeuserInfo(state, payload) {
            state.userInfo = payload.userInfo
            state.cartTotal = payload.cartTotal
        },
        initUserInfo(state) {
            state.userInfo = {
                nickName: "zhangsan",
                coin: 9999,
                headImg: require("../../assets/img/service.848ec511.png")
            },
            state.cartTotal=8
        }
    },
    actions: {
        async asyncchangeuserInfo({ commit }) {
            let user = await UserProfilesApi()
            console.log("用户信息:", user);
            commit("changeuserInfo", user.data)
        }
    }
}